<template>
	<view class="order-success">
		<!-- #ifdef APP-PLUS -->
		<top-set backgroundColor="#3595f9"></top-set>
		<tab-top page="2" fixed="true" title="抢单成功" after="true" color="#ffffff" bgColor="#3595f9" imgSrc="/static/icon/white-back.png"></tab-top>
		<!-- #endif -->
		<view class="order-top"> 
			<view class="title">
				抢单成功
			</view>
			<view class="text">
				抢单成功后，请您在30分钟内到达酒店呢...
			</view>
			<view class="ok_icon">
				<image src="/static/icon/circle-ok.png"></image>
			</view>
		</view>
		<view class="main">
			<view class="title">抢单详情</view>
			<view class="item">
				房间数量：<view style="color: #f93735;">{{order.count}}</view>间
			</view>
			<view class="item">
				预计收入：￥<view style="color: #f93735;">{{order.price}}</view>
			</view>
			<view class="item">
				房间明细：
			</view>
			<view class="item_num" v-for="(item,index) in order.newOrderArray" :key="index">
				<view class="item_num_title">{{item.storey}}楼</view>
				<view class="room" v-for="(val,key) in item.lists" :key="key">
					<view class="room_item" v-for="(v,i) in val" :key="i">
						{{v.room}}
					</view>
				</view>
			</view>
		</view>
		
		<service-information :options="order.hotelInfo"></service-information>
		
		<view class="btn">
			<view class="subscribe" @tap="subscribe">继续抢单</view>
			<view class="examine" @tap="examine(order)">查看订单</view>
		</view>
	</view>
</template>

<script>
	import serviceInformation from '@/components/cleaner/order/service-information.vue'
	export default {
		data() {
			return {
				order:{}
			}
		},
		onBackPress(e) {
			
			if(e.from == 'backbutton'){
				uni.navigateBack({
					delta: 2,
					"animationType": this.GLOBAL.backAnimation,
					"animationDuration": this.GLOBAL.animationTime
				});
				return true;
			}
			
			
		},
		onShow(){
			// #ifdef APP-PLUS
				/**
				 * 启动时,状态栏变亮
				 */
			setTimeout(()=>{
				plus.navigator.setStatusBarStyle('light');	 
			},150);
				 
			// #endif
		},
		onUnload(){
			// #ifdef APP-PLUS
				/**
				 * 页面关闭时,状态栏变暗
				 */
				plus.navigator.setStatusBarStyle('dark');
			// #endif
		},
		onLoad(e) {
			this.order = JSON.parse(e.order)
			console.log(this.order);
			let lists = this.order.orderArray1
			//数组去重
			let storeySet = new Set();
			lists.forEach(v=>{
				storeySet.add(v.storey);
			})
			let storey = [...storeySet];
			//数据整理
			let newlists1 = [];
			lists.forEach(v=>{
				storey.forEach((k,i)=>{
					if(v.storey == k){
						newlists1[i]?'':newlists1[i] =[]
						newlists1[i].push(v);
					}
				})
			})
			//数组重组
			let newlists2 = [];
			newlists1.forEach(v=>{
				let result = {};
				result.lists = [];
				for(var i = 0; i < v.length; i += 6){
					result.lists.push(v.slice(i, i + 6));
					result.storey = v[i].storey
				}
				newlists2.push(result)
			})
			//整理数据赋值
			this.order.newOrderArray = newlists2
			console.log(this.order)
		},
		methods: {
			subscribe(){
				 
				// let order = JSON.stringify(e) 
				uni.navigateBack({
					delta: 10
				});
				// this.changeTabIndex('2'); 
			},
			examine(e){
				// let order = JSON.stringify(e) 
				uni.redirectTo({
					url: '/pages/cleaner/order/will-be-cleaned' ,
					// url: '/components/hotel/hotel-order/hotel-order',
				}); 
			},
		},
		components: {
			serviceInformation
		}
	}
</script>

<style scoped lang="scss">
.order-success{
	width: 750upx;
	.ok_icon{
		width: 53upx;
		height: 53upx;
		position: absolute;
		right: 65upx;
		bottom: 129upx;
		image{
			width: 100%;
			height: 100%;
			border-radius:50%; 
		}
	}
	.order-top{
		width: 100%;
		box-sizing: border-box;
		height: 188upx;
		color: #fff;
		padding: 0 64upx;
		background-color: #3595f9;
		position: relative;
		.title{
			font-size: 32upx;
			line-height: 76upx;
		}
		.text{
			width: 480upx;
			font-size: 24upx;
			line-height: 36upx;
		}
	}
	.main{
		width: 702upx;
		padding: 30upx 24upx;
		.title{
			font-size: 32upx;
			line-height: 82upx;
		}
		.item{
			font-size: 28upx;
			line-height: 48upx;
			display: flex;
			.text{
				color: #999;
			}
		}
		.item_num{
			width: 702upx;
			.item_num_title{
				font-size: 28upx;
				line-height: 48upx;
				color: #999999;
			}
			.room:nth-child(2){
				border-radius: 0 8upx 0 0;
			}
			.room:nth-last-child(1){
				border-bottom: none;
				border-radius: 0 0 8upx 8upx;
			}
			.room:nth-last-child(1)::after{
				height: 0;
			}
			.room::after{
				position: absolute;
				left: 24upx;
				bottom: 0;
				content: '';
				width: 654upx;
				height: 2upx;
				background: #cde3f9;
			}
			.room{
				display: flex;
				align-items: center;
				justify-content: flex-start;
				height: 70upx;
				position: relative;
				background-color: #7fbcfb;
				.room_item{
					text-align: center;
					font-size: 28upx;
					line-height: 70upx;
					width: 16.666666%;
					color: #ffffff;
				}
			}
		}
	}
	.btn{
		padding: 0 120upx;
		width: 510upx;
		margin:0 0 100upx 0;	
		display: flex;
		align-items: center;
		text-align: center;
		line-height: 70upx;
		.subscribe{
			width: 240upx;
			height: 70upx;
			border-radius: 8upx;
			border: 1upx solid #3595f9;
			color: #3595f9;
			font-size: 28upx;
			margin-right: 30upx;
		}
		.examine{
			width: 240upx;
			height: 70upx;
			border-radius: 8upx;
			background-color: #3595f9;
			color: #ffffff;
			font-size: 28upx;
		}
	}
}
</style>
